import request from '@/utils/request.js'

// 查询帖子评论列表
export function listPostComments(postId, query) {
  return request.get('/app/post/comments', { ...query, postId })
}

// 发表评论
export function createComment(postId, data) {
  return request.post(`/app/post/${postId}/comment`, data)
}

// 删除评论
export function deleteComment(commentId) {
  return request.delete(`/app/comment/${commentId}`)
}

// 点赞评论
export function likeComment(commentId) {
  return request.post(`/app/comment/${commentId}/like`)
}

// 取消点赞评论
export function unlikeComment(commentId) {
  return request.post(`/app/comment/${commentId}/unlike`)
}

// 回复评论
export function replyComment(postId, commentId, data) {
  data.pid = commentId
  return request.post(`/app/post/${postId}/comment`, data)
}

export default {
  listPostComments,
  createComment,
  deleteComment,
  likeComment,
  unlikeComment,
  replyComment
}